package com.hotel.common;

/**
 * 响应状态码枚举
 * 
 * @author Hotel Management Team
 */
public enum ResultCode {

    // 通用状态码
    SUCCESS(200, "操作成功"),
    ERROR(500, "操作失败"),
    PARAM_ERROR(400, "参数错误"),
    NOT_FOUND(404, "资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不允许"),
    
    // 认证授权相关
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    TOKEN_INVALID(4001, "Token无效"),
    TOKEN_EXPIRED(4002, "Token已过期"),
    LOGIN_FAILED(4003, "登录失败"),
    ACCOUNT_DISABLED(4004, "账户已禁用"),
    PERMISSION_DENIED(4005, "权限不足"),
    
    // 业务相关状态码
    USER_NOT_FOUND(5001, "用户不存在"),
    USER_ALREADY_EXISTS(5002, "用户已存在"),
    PASSWORD_ERROR(5003, "密码错误"),
    
    // 房间相关
    ROOM_NOT_FOUND(6001, "房间不存在"),
    ROOM_NOT_AVAILABLE(6002, "房间不可用"),
    ROOM_ALREADY_OCCUPIED(6003, "房间已被占用"),
    ROOM_TYPE_NOT_FOUND(6004, "房型不存在"),
    
    // 预订相关
    RESERVATION_NOT_FOUND(7001, "预订记录不存在"),
    RESERVATION_ALREADY_CANCELLED(7002, "预订已取消"),
    RESERVATION_ALREADY_CHECKEDIN(7003, "预订已入住"),
    RESERVATION_DATE_INVALID(7004, "预订日期无效"),
    
    // 入住相关
    CHECKIN_NOT_FOUND(8001, "入住记录不存在"),
    ALREADY_CHECKEDIN(8002, "已经入住"),
    ALREADY_CHECKEDOUT(8003, "已经退房"),
    CHECKOUT_TIME_INVALID(8004, "退房时间无效"),
    
    // 会员相关
    MEMBER_NOT_FOUND(9001, "会员不存在"),
    MEMBER_ALREADY_EXISTS(9002, "会员已存在"),
    POINTS_INSUFFICIENT(9003, "积分不足"),
    
    // 财务相关
    BILL_NOT_FOUND(10001, "账单不存在"),
    BILL_ALREADY_PAID(10002, "账单已支付"),
    PAYMENT_AMOUNT_INVALID(10003, "支付金额无效"),
    INSUFFICIENT_BALANCE(10004, "余额不足");

    private final Integer code;
    private final String message;

    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    /**
     * 根据状态码获取枚举
     */
    public static ResultCode getByCode(Integer code) {
        for (ResultCode resultCode : values()) {
            if (resultCode.getCode().equals(code)) {
                return resultCode;
            }
        }
        return null;
    }

}